package com.beidouin.GnssMain.models;

/**
 * Created by flyingfluff on 2016/10/9.
 */

public class SysParam {

    public static final int FROM_NMEA = 0;
    public static final int FROM_DRIVER = 1;
    public static int dataSource = FROM_DRIVER;

    public static final int MODE_RECEIVING = 0;
    public static final int MODE_RECORDING = 1;
    public static final int MODE_REPLAYING = 2;
    private static int workStatus = MODE_RECEIVING;

    public static final int NMEA_SHOW_USED = 0;
    public static final int NMEA_SHOW_ALL = 1;
    public static int nmeaShowMode = NMEA_SHOW_USED;

    public static final int NMEA_SAVE_USED = 0;
    public static final int NMEA_SAVE_ALL = 1;
    public static int nmeaSaveMode = NMEA_SAVE_USED;

    public static final String foldername = "/iBeidou data/";
    public static String filename = "";
    //in case ConsoleActivity is not current activity, so save the info for status text
    public static boolean isShowFinishReplaying = false;
    public static int lastHour = 0;
    public static int lastMinute = 0;
    public static int lastSecond = 0;


    public static int time_hour = 0;
    public static int time_minute = 0;
    public static int time_second = 0;


    public static int replayingSpeed = 1;

    public static int getDataSource() { return dataSource; }

    public static boolean isRecording() {return (workStatus == MODE_RECORDING); }
    public static boolean isReceiving() {return (workStatus == MODE_RECEIVING); }
    public static boolean isReplaying() {return (workStatus == MODE_REPLAYING); }
    public static void setWorkStatus(int status) {
        if (status >= 0 && status <= MODE_REPLAYING)
            workStatus = status;
    }

    public static void clearTime() {
        time_hour = 0;
        time_minute = 0;
        time_second = 0;
    }

    public static String getTime() {
        return String.format("%02d:%02d:%02d", time_hour, time_minute, time_second);
    }

    public static void addTime() {
        if (++time_second >= 60) {
            time_second -= 60;
            if (++time_minute >= 60) {
                time_minute -= 60;
                ++time_hour;
            }
        }
    }

    public static void setShowLastReplay() {
        isShowFinishReplaying = true;
        lastHour = time_hour;
        lastMinute = time_minute;
        lastSecond = time_second;
    }

    public static String getLastReplayTime() {
        return String.format("%02d:%02d:%02d", lastHour, lastMinute, lastSecond);
    }
}
